#include "PlatformProperty.h"

// 3.2.7 [SW_FC_004_044]第一排座椅高度调节 1stRowSeatHeightAdjustment 实时位置反馈
SYSTEM_READ_PROPERTY(SEAT_HEIGHT_POS, int32_t) {
    builder.area(VehicleAreaSeat::ROW_1_LEFT)
        .initValue([]() {
            return 0;
        })
        .withStatusBySignals(
            []([[maybe_unused]] const PropertyStatus& lastStatus) {
                VHALOG.d("SEAT_HEIGHT_POS drvr status Change ,cc184[%d] cc472[%d], cc1173[%d]",
                         SIGNAL.getcarconfig184(), SIGNAL.getcarconfig472(), SIGNAL.getcarconfig1173());
                if (SIGNAL.carConfigIs(SignalRX::carconfig184,
                                       sdb::CarConfig184::_02,
                                       sdb::CarConfig184::_03,
                                       sdb::CarConfig184::_04) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig472,
                                       sdb::CarConfig472::_02,
                                       sdb::CarConfig472::_03) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig1173,
                                       sdb::CarConfig1173::_02)) {
                    VHALOG.d("SEAT_HEIGHT_POS drvr Active");
                    return PropertyStatus::Active;
                }
                VHALOG.d("SEAT_HEIGHT_POS drvr NotAvailable");
                return PropertyStatus::NotAvailable;
            },
            SignalRX::carconfig184,
            SignalRX::carconfig472,
            SignalRX::carconfig1173)
        .withValueBySignals(
            []([[maybe_unused]] const int32_t& last) {
                auto heightPercent = static_cast<int32_t>(SIGNAL.getDrvrSeatPosPercSeatPosHeiPerc());
                VHALOG.d("SEAT_HEIGHT_POS DRVR getDrvrSeatPosPercSeatPosHeiPerc %d", heightPercent);
                if (heightPercent >= 0 && heightPercent <= 100 &&
                    SIGNAL.getDrvrSeatPosPercSeatPosHeiQF() == sdb::Qf1::DataCalcdWithDevDefd) {
                    return heightPercent;
                }

                return last;
            },
            SignalRX::DrvrSeatPosPercSeatPosHeiPerc,
            SignalRX::DrvrSeatPosPercSeatPosHeiQF)
        .area(VehicleAreaSeat::ROW_1_RIGHT)
        .initValue([]() {
            return 0;
        })
        .withStatusBySignals(
            []([[maybe_unused]] const PropertyStatus& lastStatus) {
                VHALOG.d("SEAT_HEIGHT_POS pass status Change cc184[%d], cc472[%d], cc1174[%d]", SIGNAL.getcarconfig184(), SIGNAL.getcarconfig472(), SIGNAL.getcarconfig1174());
                if (SIGNAL.carConfigIs(SignalRX::carconfig184,
                                       sdb::CarConfig184::_04) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig472,
                                       sdb::CarConfig472::_02) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig1174,
                                       sdb::CarConfig1174::_02)) {
                    VHALOG.d("SEAT_HEIGHT_POS pass Active");
                    return PropertyStatus::Active;
                }
                VHALOG.d("SEAT_HEIGHT_POS pass NotAvailable");
                return PropertyStatus::NotAvailable;
            },
            SignalRX::carconfig184,
            SignalRX::carconfig472,
            SignalRX::carconfig1174)
        .withValueBySignals(
            []([[maybe_unused]] const int32_t& last) {
                auto heightPercent = static_cast<int32_t>(SIGNAL.getPassSeatPosPercSeatPosHeiPerc());
                VHALOG.d("SEAT_HEIGHT_POS DRVR getPassSeatPosPercSeatPosHeiPerc %d", heightPercent);
                if (heightPercent >= 0 && heightPercent <= 100 &&
                    SIGNAL.getPassSeatPosPercSeatPosHeiQF() == sdb::Qf1::DataCalcdWithDevDefd) {
                    return heightPercent;
                }
                return last;
            },
            SignalRX::PassSeatPosPercSeatPosHeiPerc,
            SignalRX::PassSeatPosPercSeatPosHeiQF);
}
